<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.beaut.project.util.FlowUtility" %>
<%@ include file="/public/header.jsp"%>
<%
	String dept_name = request.getParameter("dept_name") == null ? "0" : request.getParameter("dept_name");
	String dept_id = request.getParameter("dept_id") == null ? "0" : request.getParameter("dept_id");
%>
<html>
	<head>
		<title>部门财务统计</title>
	</head>
	<script type="text/javascript">
		$(function(){
			var titleStr="";
			titleStr="<%=dept_name%>"+"成本表";
				jQuery("#searchValue").keypress(function(e) { 
			    	// 回车键事件 
			     	if(e.which == 13) { 
			     		 doSearch();
			       	} 
				});
			$("#table").datagrid({
				title:titleStr,
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/xmFinance/listFinanceInfoByYear?dept_id=<%=dept_id%>',
				rownumbers:true,
				fitColumns:true,
				nowrap:false,
				idField:'id',
				frozenColumns:[[
				    {title:'主键',field:'id',hidden:true},
				]],
				columns:[[
					{title:'开票金额',field:'out_invoice',width:100,align:'center'},
					{title:'管理费',field:'xm_manage_price',width:100,align:'center'},
					{title:'施工单位开票',field:'work_in_invoice',width:100,align:'center'},
					{title:'开票税金',field:'company_tax',width:100,align:'center'},
					{title:'回款金额',field:'has_receivable',width:100,align:'center'},
					{title:'公共报销',field:'commonMoney',width:100,align:'center'},
					{title:'项目报销',field:'direct_reimburse',width:100,align:'center'},
					{title:'支付分包',field:'pay_work_money',width:100,align:'center'},
					{title:'支付材料款',field:'pay_purchase_money',width:100,align:'center'},
					{title:'借款（个人）',field:'loan_money',width:100,align:'center'},
					{title:'结算扣款',field:'cut_payment',width:100,align:'center'},
					{title:'现金流情况',field:'end_money',width:100,align:'center',formatter:function(value,rowData,rowIndex){
						//现金流情况的计算公式：回款金额-管理费-开票金额-公共费用报销-项目报销-支付分包-支付材料款-借款（个人）
						return parseFloat(rowData.has_receivable-rowData.xm_manage_price-rowData.company_tax-rowData.commonMoney-rowData.direct_reimburse-rowData.pay_work_money-rowData.pay_purchase_money-rowData.loan_money).toFixed(2)  ;
					}},
					{title:'毛利润',field:'profit',width:100,align:'center',formatter:function(value,rowData,rowIndex){
						//毛利润的计算公式：开票金额-管理费-施工单位开票金额-开票税金-公共报销-项目报销-支付材料款+分包扣款
						return parseFloat(rowData.out_invoice-rowData.xm_manage_price-rowData.work_in_invoice-rowData.company_tax-rowData.commonMoney-rowData.direct_reimburse-rowData.pay_purchase_money+rowData.cut_payment).toFixed(2)  ;
					}}
				]],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		function doSearch() {
			var start_time=jQuery('#start_time').datebox('getValue');  
			var end_time=jQuery('#end_time').datebox('getValue'); 
			jQuery('#table').datagrid('load', {
				start_date:start_time,
				end_date:end_time
			});
		}
	</script>
	<body  >
				<div id="table"  data-options="toolbar:'#tb'" width="100%"></div>  
								<div id="tb" style="padding:3px;height:auto">
					<div align="right">
				开始时间：<input id="start_time" name="start_time" class="easyui-datebox" style="width:100px" />&nbsp;&nbsp;&nbsp;结束时间：<input id="end_time" name="end_time" class="easyui-datebox" style="width:100px"/>
					<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>&nbsp;&nbsp;&nbsp;
			</div>
		</div>
	</body>
</html>
